package deom1;

public class Test2 {
    public static void merge(int[] nums1, int m, int[] nums2, int n) {
        int p1 = m - 1;
        int p2 = n - 1;
        int p3 = nums1.length - 1;
        while (p1 >= 0 && p2 >= 0) {
            if(nums1[p1] > nums2[p2]) {
                nums1[p3] = nums1[p1];
                p3--;
                p1--;
            } else {
                nums1[p3] = nums2[p2];
                p3--;
                p2--;
            }
        }
        if(p1 < 0) {
            while (p3 >= 0) {
                nums1[p3] = nums2[p2];
                p3--;
                p2--;
            }
        }
    }

    public static void main(String[] args) {
        int[] arr = new int[6];
        int[] str ={4,5,6,7,8,9};
        merge(arr,0,str,6);
    }
}
